import 'package:json_annotation/json_annotation.dart';
part 'hot_key_data.g.dart';

@JsonSerializable()
class HotKeyData {
  @JsonKey(name: 'data')
  List<HotKeyItemData>? data;
  @JsonKey(name: 'errorCode')
  int? errorCode;
  @JsonKey(name: 'errorMsg')
  String? errorMsg;

  HotKeyData({this.data, this.errorCode, this.errorMsg});

  factory HotKeyData.fromJson(Map<String, dynamic> json) =>
      _$HotKeyDataFromJson(json);

  static List<HotKeyData> fromList(List<Map<String, dynamic>> list) {
    return list.map(HotKeyData.fromJson).toList();
  }

  Map<String, dynamic> toJson() => _$HotKeyDataToJson(this);
}

@JsonSerializable()
class HotKeyItemData {
  @JsonKey(name: 'id')
  int? id;
  @JsonKey(name: 'link')
  String? link;
  @JsonKey(name: 'name')
  String? name;
  @JsonKey(name: 'order')
  int? order;
  @JsonKey(name: 'visible')
  int? visible;

  HotKeyItemData({this.id, this.link, this.name, this.order, this.visible});

  factory HotKeyItemData.fromJson(Map<String, dynamic> json) =>
      _$HotKeyItemDataFromJson(json);

  static List<HotKeyItemData> fromList(List<Map<String, dynamic>> list) {
    return list.map(HotKeyItemData.fromJson).toList();
  }

  Map<String, dynamic> toJson() => _$HotKeyItemDataToJson(this);
}
